package org.whb.quartz.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.whb.order.service.IAdoptOrderService;
import org.whb.quartz.constants.JobConstants;

import java.util.Map;

public class MainJob implements Job {

    @Autowired
    private IAdoptOrderService adoptOrderService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Map<String ,Object> map = (Map<String, Object>) jobExecutionContext.getJobDetail().getJobDataMap().get("params");
        String type = (String) map.get("type");
        switch (type){
            case JobConstants.JOB_TYPE_ADOPT_ORDER_PAY_CANCEL:{
                Long orderId = Long.valueOf(map.get("orderId").toString());
                adoptOrderService.cancelOrder(orderId);
            }
        }
    }
}
